home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / quicktimeintro / play movie w.controller / start code / setupcontroller.c < prev   
Encoding:
Text File  |  2000-10-06  |  2.1 KB  |  94 lines

  1. // Play Movie with Controller Sample
  2. // Based on QTShell
  3. // WWDC 2000
  4.  
  5. #include "ComApplication.h"
  6. #include "ComFramework.h"
  7. #include "MacFramework.h"
  8.  
  9. extern Rect gMCResizeBounds;    // maximum size for any movie window
  10.  
  11. //////////
  12. //
  13. // CreateController
  14. // Create and configure the movie controller.
  15. //
  16. //////////
  17.  
  18. MovieController CreateController (Movie theMovie, WindowReference theWindow, Boolean theMoveWindow)
  19. {
  20. #if TARGET_OS_WIN32
  21. #pragma unused(theMoveWindow)
  22. #endif
  23.  
  24.     MovieController            myMC = NULL;
  25.     Rect                    myRect;
  26.     WindowObject            myWindowObject = NULL;
  27.     GrafPtr                    mySavedPort;
  28.  
  29.     if ((theMovie == NULL) || (theWindow == NULL))
  30.         return(NULL);
  31.         
  32.     // get our window specific data
  33.     myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow);
  34.     if (myWindowObject == NULL)
  35.         return(NULL);
  36.         
  37.     GetPort(&mySavedPort);
  38.     MacSetPort(QTFrame_GetPortFromWindowReference(theWindow));
  39.     
  40.     // resize the movie bounding rect and offset to 0,0
  41. // Step 1. Insert Resize.clp here...
  42.  
  43. // Step 2. Insert NewMovieController.clp here...
  44.  
  45.     // set the initial looping state of the movie
  46.     QTUtils_SetLoopingStateFromFile(theMovie, myMC);
  47.     
  48.     // install an action filter that does any application-specific movie controller action processing
  49. // Step 3. Insert MCSetActionFilter.clp here...
  50.  
  51.     // add grow box for the movie controller
  52.     if ((**myWindowObject).fCanResizeWindow) {
  53. #if TARGET_OS_WIN32
  54.         RECT                myRect;
  55.  
  56.         GetWindowRect(GetDesktopWindow(), &myRect);
  57.         OffsetRect(&myRect, -myRect.left, -myRect.top);
  58.         QTFrame_ConvertWinToMacRect(&myRect, &gMCResizeBounds);
  59. #endif
  60. #if TARGET_OS_MAC
  61.         GetRegionBounds(GetGrayRgn(), &gMCResizeBounds);
  62. #endif
  63.  
  64. // Step 4. Insert MCDoAction.clp here...
  65.  
  66.     }
  67.     
  68. #if TARGET_OS_MAC
  69.     if (theMoveWindow)
  70.         MoveWindow(theWindow, kDefaultWindowX, kDefaultWindowY, false);
  71. #endif
  72.  
  73.     MacSetPort(mySavedPort);
  74.  
  75.     // add any application-specific controller functionality
  76.     SetupController(myMC);
  77.         
  78.     return(myMC);
  79. }
  80.  
  81. //////////
  82. //
  83. // SetupController
  84. // Configure the movie controller.
  85. //
  86. //////////
  87.  
  88. void SetupController (MovieController theMC)
  89. {
  90.     long            myControllerFlags;
  91.  
  92. // Step 5. Insert SetupController.clp here...
  93.  
  94. }